package h0825;

import java.util.HashSet;
import java.util.Scanner;

/**
  * @description 无重复字符的最长子串
  * @author 不知名帅哥
  * @date 2024/8/25 12:01
  * @version 1.0
*/
public class TheLongestSubDuplicate {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s = sc.nextLine();
        int res=getRes(s);
        System.out.println(res);
    }

    private static int getRes(String s) {
        HashSet<Character> set = new HashSet<>();
        int left=0;
        int right=0;
        int ans=0;
        //滑动窗口的解法
        for ( right = 0; right < s.length() ; right++) {
            while (set.contains(s.charAt(right))){
                set.remove(s.charAt(left));
                left++;
            }
            set.add(s.charAt(right));
            ans=Math.max(ans,right-left+1);
        }
        return ans;
    }
}
